function [s1]=encode(mulaw)
%1-st step
mulaw = bitxor (mulaw , 255);
%2-nd step
exponent = bitand (bitshift(mulaw , -4) , 7);
%3-rd step
mantissa = bitand (mulaw , 15) + 16;
%4-th step
adjusted = bitshift(mantissa , +(exponent + 3)) - 128 - 4;
%5-th step
if bitand(mulaw,128) == 0
    adjusted = -adjusted;
end
%6-th step
s1 = adjusted;